

import { AxiosResponse } from "axios";
import http from "..";
import { Resource, ResourceBody } from "../../pages/resouce";

//上传xlsx文件数据
export function uploadRouce(list: ResourceBody[]): Promise<AxiosResponse> {
    return http.post("/admin/resource/load/file", JSON.stringify(list), {
        headers: { "Content-Type": "application/json;charset=UTF-8" },
        responseType: 'blob'
    })
}

export interface ResourceParam {
    current: number,
    size: number,
    screen: number,
    company?: string,
    phone?: string,
    corpName?: string
}

export interface ResourceResult {
    total: number,
    resources: Resource[]
}

export function resouceQuery(param: ResourceParam): Promise<AxiosResponse<ResourceResult>> {
    return http.get("/admin/resource/paging", {
        params: param
    })
}


export function resouceAdd(params: URLSearchParams): Promise<AxiosResponse<string>> {
    return http.post("/admin/resource/add", params)
}


export function bacthSendSms(size: number): Promise<AxiosResponse<string>> {
    return http.get("/admin/short/link/create?size=" + size)
}


export function addRemarkInfo(params: URLSearchParams): Promise<AxiosResponse<string>> {
    return http.post("/admin/remark/add", params)
}


export function updateRemarkInfo(params: URLSearchParams): Promise<AxiosResponse<string>> {
    return http.post("/admin/remark/update", params)
}

export function removeRemarkInfo(params: URLSearchParams): Promise<AxiosResponse<string>> {
    return http.post("/admin/remark/remove", params)
}

export function updateSendStatus(params: URLSearchParams): Promise<AxiosResponse<string>> {
    return http.post("/admin/sms/update/status", params)
}

export function linkGet(code: string): Promise<AxiosResponse<string>> {
    return http.get(`/admin/sms/get/link?code=${code}`)
}